package com.ruoyi.background.domain;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户答题详情对象 app_site_topic_user_detail
 *
 * @author susu
 * @date 2024-08-27
 */
public class AppSiteTopicUserDetail extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    private Long id;

    /**
     * 记录的id
     */
    @Excel(name = "记录的id")
    private Long recordId;

    /**
     * 题目
     */
    @Excel(name = "题目")
    private String title;

    /**
     * 答案
     */
    @Excel(name = "答案")
    private String answer;

    /**
     * 用户答案
     */
    @Excel(name = "用户答案")
    private String userAnswer;

    /**
     * 0对 1错误
     */
    @Excel(name = "0对 1错误")
    private Integer isRight;

    /**
     * 选项1
     */
    @Excel(name = "选项1")
    private String choose1;

    /**
     * 选项2
     */
    @Excel(name = "选项2")
    private String choose2;

    /**
     * 选项3
     */
    @Excel(name = "选项3")
    private String choose3;

    /**
     * 选项4
     */
    @Excel(name = "选项4")
    private String choose4;

    /**
     * 题目类型
     */
    @Excel(name = "题目类型")
    private Integer topicType;

    /**
     * 解析
     */
    @Excel(name = "解析")
    private String parse;

    private String typeName;


    private List<Map<String, String>> chooseList;


    public void initData() {
        if (this.topicType == 1 || this.topicType == 3) {
            this.typeName = this.topicType == 1 ? "单选题" : "判断题";
        } else if (this.topicType == 2) {
            this.typeName = "多选题";
        }
        this.chooseList = new ArrayList<>();
        if (!ObjectUtils.isEmpty(this.choose1)) {
            Map<String, String> res = new HashMap<>();
            res.put("label", this.choose1);
            if (this.answer.contains("A")) {
                res.put("backgroundColor", "#99ECC0");
            }
            if (this.isRight == 1 && this.userAnswer.contains("A") && this.topicType != 2) {
                res.put("backgroundColor", "#EEA9A2");
            }

            chooseList.add(res);
        }
        if (!ObjectUtils.isEmpty(this.choose2)) {
            Map<String, String> res = new HashMap<>();
            res.put("label", this.choose2);
            if (this.answer.contains("B")) {
                res.put("backgroundColor", "#99ECC0");
            }
            if (this.isRight == 1 && this.userAnswer.contains("B") && this.topicType != 2) {
                res.put("backgroundColor", "#EEA9A2");
            }
            chooseList.add(res);
        }
        if (!ObjectUtils.isEmpty(this.choose3)) {
            Map<String, String> res = new HashMap<>();
            res.put("label", this.choose3);
            if (this.answer.contains("C")) {
                res.put("backgroundColor", "#99ECC0");
            }
            if (this.isRight == 1 && this.userAnswer.contains("C") && this.topicType != 2) {
                res.put("backgroundColor", "#EEA9A2");
            }
            chooseList.add(res);
        }
        if (!ObjectUtils.isEmpty(this.choose4)) {
            Map<String, String> res = new HashMap<>();
            res.put("label", this.choose4);
            if (this.answer.contains("D")) {
                res.put("backgroundColor", "#99ECC0");
            }
            if (this.isRight == 1 && this.userAnswer.contains("D") && this.topicType != 2) {
                res.put("backgroundColor", "#EEA9A2");
            }
            chooseList.add(res);
        }
    }


    public List<Map<String, String>> getChooseList() {
        return chooseList;
    }

    public void setChooseList(List<Map<String, String>> chooseList) {
        this.chooseList = chooseList;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setRecordId(Long recordId) {
        this.recordId = recordId;
    }

    public Long getRecordId() {
        return recordId;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public String getAnswer() {
        return answer;
    }

    public void setUserAnswer(String userAnswer) {
        this.userAnswer = userAnswer;
    }

    public String getUserAnswer() {
        return userAnswer;
    }

    public void setIsRight(Integer isRight) {
        this.isRight = isRight;
    }

    public Integer getIsRight() {
        return isRight;
    }

    public void setChoose1(String choose1) {
        this.choose1 = choose1;
    }

    public String getChoose1() {
        return choose1;
    }

    public void setChoose2(String choose2) {
        this.choose2 = choose2;
    }

    public String getChoose2() {
        return choose2;
    }

    public void setChoose3(String choose3) {
        this.choose3 = choose3;
    }

    public String getChoose3() {
        return choose3;
    }

    public void setChoose4(String choose4) {
        this.choose4 = choose4;
    }

    public String getChoose4() {
        return choose4;
    }

    public void setTopicType(Integer topicType) {
        this.topicType = topicType;
    }

    public Integer getTopicType() {
        return topicType;
    }

    public void setParse(String parse) {
        this.parse = parse;
    }

    public String getParse() {
        return parse;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("recordId", getRecordId())
                .append("title", getTitle())
                .append("answer", getAnswer())
                .append("userAnswer", getUserAnswer())
                .append("isRight", getIsRight())
                .append("choose1", getChoose1())
                .append("choose2", getChoose2())
                .append("choose3", getChoose3())
                .append("choose4", getChoose4())
                .append("topicType", getTopicType())
                .append("parse", getParse())
                .append("createTime", getCreateTime())
                .toString();
    }
}
